<!--
 * @Description: 
 * @Version: 1.0
 * @Author: Yuanjy
 * @Date: 2020-04-28 11:06:50
 * @LastEditors: Yuanjy
 * @LastEditTime: 2020-04-28 11:09:37
 -->
<template>
  <div>
    <el-button :disabled="data.id === 1" size="mini" type="success" @click="to(data.id)">编辑</el-button>
    <!-- <el-tooltip content="编辑用户" placement="top">
      <svg-icon class-name="edit-icon" icon-class="edit" @click.native="to(data.id)"/>
    </el-tooltip> -->
    <eForm ref="form" :roles="roles" :sup_this="sup_this" :is-add="false"/>
  </div>
</template>
<script>
import eForm from './form'
export default {
  components: { eForm },
  props: {
    roles: {
      type: Array,
      required: true
    },
    data: {
      type: Object,
      required: true
    },
    // index.vue 的this 可用于刷新数据
    sup_this: {
      type: Object,
      required: true
    }
  },
  methods: {
    to(id) {
      const _this = this.$refs.form
      _this.roleIds = []
      _this.form = {
        id: this.data.id,
        name: this.data.name,
        item: this.data.item,
        is_punch: this.data.is_punch,
        time_limit: this.data.time_limit,
        start: this.data.start,
        end: this.data.end,
        is_give_score: this.data.is_give_score,
        score: this.data.score,
        is_comment: this.data.is_comment,
        is_score: this.data.is_score,
        score_rate: this.data.score_rate,
        punch_icon: this.data.punch_icon,
        description: this.data.description,
        is_prompt: this.data.is_prompt,
        is_lock: this.data.is_lock,
        collect_music: this.data.collect_music,
        sample: this.data.sample
      }
      _this.dialog = true
    }
  }
}
</script>

<style scoped>
  div{display: inline-block;margin-right: 3px;}
  .edit-icon {
  width: 1.5em;
  height: 1.5em
}
</style>
